/*
 * @Author: jiangh1 1141429595@qq.com
 * @Date: 2023-07-14 10:46:38
 * @LastEditors: jiangh1 1141429595@qq.com
 * @LastEditTime: 2023-07-14 10:46:58
 * @FilePath: \react-js-demo\src\http\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import axios from 'axios'
import config from '@/config'
class Http {

  async get (url, params = {}, header = {}) {
    this.SetBaseUrl()
    return await axios.get(url, { 
      params: params,
      headers: header
    })
  }

  async post (url, params = {}, header = {}) {
    this.SetBaseUrl()
    return await axios.post(url, params, {
      headers: header
    })
  }

  SetBaseUrl () {
    if (axios.defaults.baseURL == null) {
      axios.defaults.baseURL = config.check();
    }
  }
}

export default new Http()
